var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/org-tree/index.tsx
var org_tree_exports = {};
__export(org_tree_exports, {
  OrgTree: () => OrgTree
});
module.exports = __toCommonJS(org_tree_exports);
var import_react = require("react");
var import_functionalComponent = require("../../functionalComponent");
var import_util = require("../../util");
async function getOrgTree(data) {
  const res = await import_util.iup.request.get({
    url: "/basedata/org/getCompleteOrgTree",
    data
  });
  if ((res == null ? void 0 : res.code) === 0) {
    return (res == null ? void 0 : res.data) ?? [];
  } else {
    return [];
  }
}
var defaultProps = {
  /**
   * @description       权限
   * @default           true
   */
  dataAccessAuth: true,
  // 权限
  orgInnerType: "2",
  // 组织树的权限类型： 1 登录组织权限、2数据查询组织权限
  containLowCu: true,
  // 包含单元
  containDept: false,
  // 包含部门
  containProject: false,
  // 包含项目
  enableManagerContrl: false,
  // 启用管理员数据权限
  orgNo: ""
  // 只显示此组织
  // userNo: '' // 按此用户过滤组织
};
var OrgTree = (0, import_util.compHoc)((props) => {
  const {
    defaultSelectedFirstNode,
    defaultChange = true,
    params,
    outRef,
    treeRequest,
    beforeRequest,
    convertNode: originConvertNode,
    ...others
  } = props;
  const convertNode = (0, import_util.useRefCallback)((node, levelIndex) => {
    if (defaultSelectedFirstNode && levelIndex.level === 0 && levelIndex.index === 0) {
      node.isSelected = true;
    }
    return originConvertNode ? originConvertNode(node, levelIndex) : node;
  });
  const requestParams = (0, import_react.useMemo)(() => {
    return { ...defaultProps, ...params };
  }, [params]);
  const request = (0, import_util.useRefCallback)(async (param) => {
    if (await (beforeRequest == null ? void 0 : beforeRequest(param)) !== false) {
      if (treeRequest) {
        return await treeRequest(param);
      }
      return await getOrgTree(param);
    }
    return [];
  });
  return /* @__PURE__ */ React.createElement(
    import_functionalComponent.AsyncTree,
    {
      ref: outRef,
      request,
      params: requestParams,
      convertNode,
      defaultChange,
      ...others
    }
  );
}, "OrgTree");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  OrgTree
});
